<template>
	<view class="container">
		<map class="map" id="map" :longitude="longitude" :scale="scale" :markers="markers" :latitude="latitude" scale="16" >
			<!-- <cover-view class="park_info">
				<cover-view class="name">百联又一城商业大厦停车场</cover-view>
				<cover-view class="site">
					<cover-image class="s_icon" src="../../static/img/site.png"></cover-image>
					<cover-view class="s_txt">600米 | 上海市杨浦区百联邯郸路100号</cover-view>
				</cover-view>
				<cover-view class="time">
					<cover-view class="txt1">￥10</cover-view>
					<cover-view class="txt2">/小时</cover-view>
				</cover-view>
				<cover-image class="nav" src="../../static/img/nav_icon.png"></cover-image>
			</cover-view> -->
		</map>
	</view>
</template>

<script>
	export default {
	    data() {
	        return {
				type:'',
	         id:0, // 使用 marker点击事件 需要填写id
	            title: 'map',
	            latitude:"",
	            longitude:"",
				scale:8,
				markers:[],
	            covers: [{
					width:16,
	                latitude: "",
	                longitude: "",
	            }]
	        }
	    },
		onLoad({type}) {
			this.type = type
		},
		onShow() {
			let  latitude
			let longitude
			let iconPath
			if(this.type == 1){
				latitude = this.defaultAddress.latitude
				longitude = this.defaultAddress.longitude
				iconPath = 'https://willmid-img.oss-cn-shanghai.aliyuncs.com/2021/11/25/441a3153961b287cb03513cb39a6cb09.png'
			}else{
				latitude = this.defaultAddress.parking_latitude
				longitude = this.defaultAddress.parking_longitude
				iconPath = 'https://willmid-img.oss-cn-shanghai.aliyuncs.com/2021/11/18/parck.png'
			}
			var that =this
			uni.getLocation({
				type: 'wgs84',
				success: function (res) {
					console.log('当前位置的经度：' + res.longitude,that.currentLocation.longitude);
					console.log('当前位置的纬度：' + res.latitude,that.currentLocation.latitude);
					let long
					let lat
					if(that.isAuth){
						lat=that.currentLocation.latitude
						long=that.currentLocation.longitude
					}else{
						lat=res.latitude
						long=res.longitude
					}
					that.latitude=lat
					that.longitude=long
					let arr =[
						{
							id:0,
							longitude:long,
							latitude:lat,
						},
						{
							id:1,
							longitude:longitude,
							latitude:latitude,
							iconPath:iconPath,
							width:32,
						}
					]
					that.markers = arr
					console.log(that.markers)
				}
			})
			// console.log(this.covers,this.latitude,this.longitude)
		},
	    methods: {
	
	    }
	}
</script>

<style scoped lang="scss">
	.map{
		width: 100%;
		height: 100vh;
	}
	
</style>
